let baseURL='http://192.168.199.101:8080/Baor/'

function ajaxHttp(method,url,data){
    return new Promise((resolve,reject)=>{
      var request=new XMLHttpRequest();

        request.open(method,baseURL+url)
        request.setRequestHeader("Content-type","application/json");
        request.send(JSON.stringify(data));
        request.onload=function(){
            resolve(request.responseText)
        }
        request.onerror=function () {
            reject("网络请求失败")
        }
    })
 }

//  let baseURL="http://192.168.199.101:8080/Baor/"
//  function ajaxHttp(method,url,data){
//     return new Promise((resolve,reject)={
//         var request=new XMLHttpRequest()
//         request.open(method,baseURL+url)//method--请求方式--“GET，POST”逗号后面跟随路径地址
//         request.setRequestHeader("Content-type","application/json");
//         request.send(JSON.stringify(data))
//         request.onload=function(){
//             resolve(request.responseText)//请求成功所作的事情
//         }
//         request.onerror=function(){
//             reject("请求失败")//请求失败所作的事情
//         }
//     })
//  }